package org.edu.modules.classChoise.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.edu.common.api.vo.Result;
import org.edu.common.aspect.annotation.AutoLog;
import org.edu.common.system.base.controller.BaseController;
import org.edu.common.system.query.QueryGenerator;
import org.edu.modules.classChoise.entity.JwKechengClass;
import org.edu.modules.classChoise.service.IJwKechengClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
* @Description: 教务课程信息
* @Author: jeecg-boot
* @Date:   2021-04-15
* @Version: V1.0
*/
@Api(tags="选课模式")
@RestController
@RequestMapping("/classChoise/veJwKecheng")
@Slf4j
public class JwKechengClassController extends BaseController<JwKechengClass, IJwKechengClassService> {
   @Autowired
   private IJwKechengClassService jwKechengService;

   /**
    * 分页列表查询
    *
    * @param jwKecheng
    * @param pageNo
    * @param pageSize
    * @param req
    * @return
    */
   @AutoLog(value = "教务课程信息-分页列表查询")
   @ApiOperation(value="课程列表查询", notes="教务课程信息-分页列表查询")
   @PostMapping(value = "/list")
   public Result<?> queryPageList( JwKechengClass jwKecheng,
                                  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                  HttpServletRequest req) {
       String kcmc = jwKecheng.getKcmc();
       if(kcmc!= null && !kcmc.equals("")) {
           jwKecheng.setKcmc(null);
       }
       QueryWrapper<JwKechengClass> queryWrapper = QueryGenerator.initQueryWrapper(jwKecheng, req.getParameterMap());
       if(kcmc!= null && !kcmc.equals("")) {
           queryWrapper.like("kcmc", kcmc);
       }
       Page<JwKechengClass> page = new Page<JwKechengClass>(pageNo, pageSize);
       IPage<JwKechengClass> pageList = jwKechengService.page(page, queryWrapper);
       return Result.OK(pageList);

   }



}
